<?php
class Testimonials_Model extends ORM {
	
	protected $table_name = 'testimonials';
	protected $primary_key = 'testimonials_id';
	protected $col_sort_order = 'testimonials_sort_order';
	protected $col_status = 'testimonials_status';
	protected $sorting = array('testimonials_id' => 'desc');
	
	public function get()
	{
		$this->db->from($this->table_name);
		$this->db->select('*');
		$this->db->orderby($this->col_sort_order,'desc');
		$this->db->orderby($this->primary_key,'desc');
		$query = $this->db->get();
		if($query->count() > 0)
			return $query->result_array(false);
		else
			return false;
	}
	
	public function get_with_active($language)
	{
		$this->db->select('*');
		$this->db->from($this->table_name);
		$this->db->join('testimonials_content', 'testimonials_content.testimonials_id', 'testimonials.testimonials_id');
		$this->db->where('testimonials_content.languages_id',$language);
		$this->db->where($this->col_status,'1');
		$this->db->orderby('testimonials.'.$this->col_sort_order,'desc');
		$this->db->orderby('testimonials.'.$this->primary_key,'desc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
	public function count_row()
	{
		$this->db->select('COUNT('.$this->primary_key.') AS max');
		$this->db->from($this->table_name);
        $this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
	}
	public function get_oder()
	{
		$this->db->from($this->table_name);
		$this->db->select($this->primary_key);
		$this->db->orderby($this->col_sort_order,'asc');
		$query = $this->db->get();
		return $query->result_array(false);
		
	}
}
?>